package com.whfc.ms.api.fim.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.common.util.DateUtil;
import com.whfc.fim.dto.FimResultAnalysisDTO;
import com.whfc.fim.dto.FimResultDTO;
import com.whfc.fim.dto.FimResultRateContDTO;
import com.whfc.fim.dto.FimWarnAnalysisDTO;
import com.whfc.fim.param.FimAlgResultDelParam;
import com.whfc.fim.param.FimResultBatchHandleParam;
import com.whfc.fim.param.FimResultEditParam;
import com.whfc.fim.service.FimResultService;
import com.whfc.ms.api.fim.service.MsFimResultService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 智能监控报警记录 service
 *
 * @author : qzexing
 * @version : 1.0
 * @date : 2020-09-08 20:05
 */
@Service
public class MsFimResultServiceImpl implements MsFimResultService {

    @DubboReference(interfaceClass = FimResultService.class, version = "1.0.0")
    private FimResultService fimResultService;

    @Override
    public PageData<FimResultDTO> list(Integer pageNum, Integer pageSize, Integer deptId, Integer handleStatus,
                                       Integer algCheckType, Date startTime, Date endTime) {
        PageData<FimResultDTO> pageData = fimResultService.list(pageNum, pageSize, deptId, handleStatus, algCheckType, startTime, endTime);
        return pageData;
    }

    @Override
    public void del(FimAlgResultDelParam param) {
        fimResultService.del(param);
    }


    @Override
    public FimResultDTO detail(Integer resultId) {
        return fimResultService.detail(resultId);
    }

    @Override
    public void handle(FimResultEditParam editParam) {
        fimResultService.handle(editParam);
    }

    @Override
    public void batchHandle(FimResultBatchHandleParam param) {
        fimResultService.batchHandle(param);
    }

    @Override
    public FimResultAnalysisDTO analysis(Integer deptId, Date startTime, Date endTime) {
        return fimResultService.analysis(deptId, startTime, endTime);
    }

    @Override
    public FimResultAnalysisDTO analysis(Integer deptId, Date date) {
        return fimResultService.analysis(deptId, date);
    }

    @Override
    public ListData<FimResultRateContDTO> warnNumstatic(Integer deptId, Integer handleStatus, Date startTime, Date endTime) {
        List<FimResultRateContDTO> list = fimResultService.warnNumstatic(deptId, handleStatus, startTime, endTime);
        return new ListData<>(list);
    }

    @Override
    public FimWarnAnalysisDTO analysisByHour(Integer deptId, Date date) {
        Date startTime = DateUtil.getDateBegin(date);
        Date endTime = DateUtil.getDateEnd(date);
        return fimResultService.analysisByHour(deptId, startTime, endTime);
    }

    @Override
    public FimWarnAnalysisDTO analysisByDate(Integer deptId, Date month) {
        Date startDate = DateUtil.getMonthBegin(month);
        Date endDate = DateUtil.getMonthEnd(month);
        return fimResultService.analysisByDate(deptId, startDate, endDate);
    }

}
